package com.tools.commons.utils;

import java.util.Random;

public class CodeGeneratorUtil {
    private static final int DEFAULT_LENGTH = 6;

    private CodeGeneratorUtil() {
    }

    public static String randCode() {
        return randCode(DEFAULT_LENGTH);
    }

    public static String randCode(int length) {
        int max = 8;
        int min = 1;
        for (int i = 1; i < length; i++) {
            max = max * 10 + 9;
            min *= 10;
        }
        return String.valueOf(new Random().nextInt(max) | min);
    }

}
